package ModelLayer;
import java.util.ArrayList;


/**
 * Write a description of class Dummy here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class PersonContainer
{
    // instance variables - replace the example below with your own
    private ArrayList<Person> pc;
    private ArrayList<String> list;

    /**
     * Constructor for objects of class Dummy
     */
    public PersonContainer()
    {
        pc = new ArrayList<Person>();
        list = new ArrayList<String>();
    }
    public void addPerson(Person p)
    {
        pc.add(p);
    }
    public Person createPerson(int id, String name, String address, int zipCode, String city, String phone)
    {
       
            Person p = new Person(id, name, address, zipCode, city, phone);
            
        return p;
    }
    public Person findPerson(int id)
    {
        int i = 0;
        boolean found = false;
        while(!found && i < pc.size())
        {
            Person n = pc.get(i);
            if(id == n.getId())
            {
        
                found = true;
            }
            else
            {
                i++;
            }
        }
        if(found)
        {
            return pc.get(i);
        }
        else 
        {
            return null;
        }
    }
    public void deletePerson(int _id)
    {
        pc.remove(findPerson(_id));
    }
    public ArrayList<String> showAllPersons()
    {
        for(Person listName : pc)
        {
            list.add(listName.getName());
        }
        return list;
    }
}
